home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tricks of the Mac Game Programming Gurus
/
TricksOfTheMacGameProgrammingGurus.iso
/
More Source
/
C⁄C++
/
E-Z Progress Bar 1.0a
/
Environ.cp
< prev
next >
Wrap
Text File
|
1995-03-08
|
3KB
|
187 lines
#define TrapMask 0x0800
#include "Environ.h"
enum { rNeeded=128, iSNeeded=1 };
long NumToolboxTraps()
{
long trapTableSize;
if (NGetTrapAddress(_InitGraf, ToolTrap) ==
NGetTrapAddress(0xAA6E, ToolTrap))
return(0x0200);
else if (!Gestalt(gestaltToolboxTable, &trapTableSize))
return (short) trapTableSize;
return (0x0400);
}
/* Why/How NumToolboxTraps works (Inside Mac):
Macintosh Plus and Macintosh SE computers with system software prior
to System 7 masked their trap numbers with $1FF in the
GetToolboxTrapAddress function so that the address of A-line instruction
$AA6E (whether implemented or not) would be the same as A-line instruction $A86E,
which invokes the InitGraf routine
Which means that if _InitGraf (0xAA86E) points to the same address as 0xAA6E,
then it's system software prior to System 7, which means only 0x0200 traps available
*/
/* Think Ref says Think C 5.0 and greater contain glue for Gestalt
for systems < 6.0.4 and the following can be obtained from Gestalt calls
for systems < 6.0.4:
gestaltVersion
gestaltMachineType
gestaltSystemVersion
gestaltProcessorType
gestaltFPUType
gestaltQuickdrawVersion
gestaltKeyBoardType
gestaltAppleTalkVersion
gestaltMMUType
gestaltPhysicalRamSize
gestaltLogicalRamSize
*/
TrapType GetTrapType(short theTrap)
{
if ((theTrap & TrapMask) > 0)
return(ToolTrap);
else
return(OSTrap);
}
Boolean TrapAvailable(short theTrap)
{
TrapType tType;
tType = GetTrapType(theTrap);
if (tType == ToolTrap)
theTrap = theTrap & 0x07FF;
if (theTrap >= NumToolboxTraps())
theTrap = _Unimplemented;
return (NGetTrapAddress(theTrap, tType) !=
NGetTrapAddress(_Unimplemented, ToolTrap));
}
long OSTableSize()
{
return GenericGestalt(gestaltOSTable);
}
long SystemVersion()
{
return GenericGestalt(gestaltSystemVersion);
}
long ROMSize()
{
return GenericGestalt(gestaltROMSize);
}
long ROMVersion()
{
return GenericGestalt(gestaltROMVersion);
}
long CPUType()
{
return GenericGestalt(gestaltProcessorType);
}
long FPUType()
{
return GenericGestalt(gestaltFPUType);
}
long QDVersion()
{
return GenericGestalt(gestaltQuickdrawVersion);
}
long RGBAvailable()
{
return (TrapAvailable(_RGBForeColor));
}
Boolean ColorQD()
{
return (QDVersion());
}
Boolean PopUps()
{
if (!Gestalt(gestaltPopupAttr, nil))
return 1;
else
return 0;
}
Boolean OffScreenGWorlds()
{
long result=QDVersion();
if (result>=gestalt32BitQD)
return 1;
return 0;
}
Boolean ColorScreen()
{
return 0;
}
long NumMonitors()
{
return 0;
}
long GenericGestalt(long selectorCode)
{
long theResult;
if (!Gestalt(selectorCode, &theResult))
return theResult;
else
return 0;
}
Boolean System7Savvy()
{
long qdVersion, systemVersion;
if (TrapAvailable(_WaitNextEvent) &&
(!Gestalt(gestaltQuickdrawVersion, &qdVersion)) &&
(!Gestalt(gestaltPopupAttr, nil)) &&
(!Gestalt(gestaltSystemVersion, &systemVersion))
)
return ((qdVersion>=0x230) && (systemVersion>=0x700));
else
return 0;
}
long PhysicalRAM()
{
return GenericGestalt(gestaltPhysicalRAMSize);
}
long LogicalRAM()
{
return GenericGestalt(gestaltLogicalRAMSize);
}
long LowMemorySize()
{
return GenericGestalt(gestaltLowMemorySize);
}
long KeyboardType()
{
return GenericGestalt(gestaltKeyboardType);
}
Boolean WaitNextEventHere()
{
return TrapAvailable(_WaitNextEvent);
}